<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      th,
      tr,
      td,
      table {
        border: 1px solid #ccc;
        margin: 0 auto;
        border-collapse: collapse;
      }
      th,
      td {
        padding: 10px 20px;
        text-align: center;
      }
      th {
        background-color: #f0f0f0;
      }
      tr:nth-child(2n) {
        background-color: #f0f0f0;
      }
      h2 {
        text-align: center;
      }
    </style>
  </head>
  <body>
    <table>
      <tr>
        <th>名次</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>销售额</th>
        <th>业绩状态</th>
      </tr>
      <script>
        let sales = [
          { name: '小明', age: 18, gender: '男', money: 30, status: 0 },
          { name: '小红', age: 26, gender: '女', money: 99, status: 3 },
          { name: '小刚', age: 19, gender: '男', money: 88, status: 2 },
          { name: '小丽', age: 20, gender: '女', money: 67, status: 1 },
          { name: '晓强', age: 23, gender: '女', money: 77, status: 1 },
          { name: '小张', age: 25, gender: '女', money: 80, status: 2 },
        ]
        const obj = {
          0: '未及格',
          1: '及格',
          2: '良好',
          3: '优秀',
        }
        function apt(c, obj) {
          c.sort(function (a, b) {
            return b.money - a.money
          })
          for (let i = 0; i < c.length; i++) {
            c[i].money = `${c[i].money}w`
            c[i].status = obj[c[i].status]
          }
          for (let i = 0; i < c.length; i++) {
            document.write(` <tr>
          <th>${i + 1} </th>
          <th>${c[i].name}</th>
          <th>${c[i].age}</th>
          <th>${c[i].gender}</th>
          <th>${c[i].money}</th>
          <th>${c[i].status}</th>
        </tr> `)
          }
        }
        apt(sales, obj)
      </script>
    </table>
  </body>
</html>
